


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../model/position_model.dart';

class ChannelCell extends StatefulWidget {

  ValueChanged<ChannelModel> selectRespond;

  ChannelModel channelModel;

   ChannelCell({super.key,required this.channelModel, required this.selectRespond});

  @override
  State<ChannelCell> createState() => _ChannelCellState();
}

class _ChannelCellState extends State<ChannelCell> {


  @override
  Widget build(BuildContext context) {
    return GestureDetector(onTap: (){

        widget.selectRespond(widget.channelModel!);

    },child: Container(
      margin: EdgeInsets.only(bottom: 10),
      width: 170,
      height: 38,
      color:widget.channelModel.select!?Colors.grey:Color(0xFFF0F0F0),
      child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
        Container(
          width: 80,
          padding: EdgeInsets.only(left: 20),
          child: Text("CH_${widget.channelModel!.index}",
              style: TextStyle(
                  color: Color(0xFF333333),
                  fontSize: 16,
                  fontWeight: FontWeight.w500)),
        ),
        Container(
          height: 20,
          width: 1,
          color: Color(0xFFCDCDCD),
        ),
        Container(
          width: 50,
          child: Text("${widget.channelModel!=null && widget.channelModel.value!>0?widget.channelModel.value:'--'}",
              style: TextStyle(
                  color: Color(0xFF333333),
                  fontSize: 16,
                  fontWeight: FontWeight.w500)),
        ),
        Container(
          width: 28,
          child: Text("℃",
              style: TextStyle(
                  color: Color(0xFF333333),
                  fontSize: 16,
                  fontWeight: FontWeight.w500)),
        ),
      ]),
    ));
  }
}


